import { service } from '@/service'

enum Api {
  tree = 'hbsys-system/dept/deptTreeInfo',
  mechanism = 'hbsys-system/dept/mechanism',
  dept = 'hbsys-system/dept/mechanism',
  leader = 'hbsys-system/dept/mechanismLeader',
  list = 'hbsys-system/user/list',
  listAll = 'hbsys-system/user/listAll',
  add = 'hbsys-system/user',
  details = 'hbsys-system/user/userDetail',
  transfer = 'hbsys-system/user/transfer',
  transferList = 'hbsys-system/user/transferList',
  cancel = 'hbsys-system/user/transfer/cancel'
}

export const getTree = (params?: any) => {
  return service.request({
    url: Api.tree,
    method: 'GET',
    params
  })
}
export const deptTreeInfoAll = (params?: any) => {
  return service.request({
    url: 'hbsys-system/dept/deptTreeInfoAll',
    method: 'GET',
    params
  })
}

export const newDeptTreeInfoAll = (
  parentId = 'GO_56a669e360524a4997b8e3445bf029c8'
) => {
  return service.request({
    url: `hbsys-system/dept/deptTreeInfoByParentId/${parentId}`,
    method: 'GET'
  })
}

export const getMechanism = (params?: any) => {
  return service.request({
    url: Api.mechanism,
    method: 'GET',
    params
  })
}

export const getDept = (id?: any) => {
  return service.request({
    url: Api.dept + '/' + id,
    method: 'GET'
  })
}
export const getLeader = (id?: any) => {
  return service.request({
    url: Api.leader + '/' + id,
    method: 'GET'
  })
}

export const getList = (params?: any) => {
  return service.request({
    url: Api.list,
    method: 'GET',
    params
  })
}
export const getListAll = (params?: any) => {
  return service.request({
    url: Api.listAll,
    method: 'GET',
    params
  })
}
export const addList = (data?: any) => {
  return service.request({
    url: Api.add,
    method: 'POST',
    data
  })
}
export const editList = (data?: any) => {
  return service.request({
    url: Api.add,
    method: 'post',
    data
  })
}
export const delList = (data?: any) => {
  return service.request({
    url: Api.add,
    method: 'DELETE',
    data
  })
}
export const details = (id?: any) => {
  return service.request({
    url: Api.details + '/' + id,
    method: 'GET'
  })
}

export const removedPost = (data?: any) => {
  return service.request({
    url: Api.transfer,
    method: 'POST',
    data
  })
}
export const getTransferList = (params?: any) => {
  return service.request({
    url: Api.transferList,
    method: 'GET',
    params
  })
}
export const revocation = (params?: any) => {
  return service.request({
    url: Api.cancel,
    method: 'POST',
    params
  })
}
